//
//  LTHmEcgDrawLineView.h
//  TH_HM_CombineSDKTestDemo
//
//  Created by lanzhongping on 2020/11/21.
//  Copyright © 2020 None. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@class LTHmEcgDrawLineModel;

typedef NS_ENUM(NSUInteger, HORIZONTAL_SPEED) {
    HORIZONTAL_SPEED_DEFAULT, // 25 mm/s
    HORIZONTAL_SPEED_DOUBLE,  // 50 mm/s
};


typedef NS_ENUM(NSUInteger, VERTIAL_GAIN) {
    VERTIAL_GAIN_HALF,      //5 mm/mv
    VERTIAL_GAIN_DEFAULT,   //10 mm/mv
    VERTIAL_GAIN_DOUBLE,    //20 mm/mv
};

/*
 in iOS
 1pt = 25.4/163 mm;
 1mm = 163/25.4 pt
 */
#define INCH_TO_PT (sqrtf(powf(480.0f, 2.0f) + powf(320.0f, 2.0f)) / 3.5f)
#define TRANS_MM_TO_PT ( 163.0f / 25.4f)  //1mm
#define TRANS_PT_TO_MM  (25.4f/ 163.0f)
//#define LINE_OR_BAR_COUNTS(x)  ((NSInteger)((x) * 25.4f/ 163.0f))

#define LINE_OR_BAR_COUNTS(x)  (round( (x) * 25.4f/ 163.0f ))

#define ECG_BACKGROUND_COLOR_DEFAULT ( [UIColor colorWithRed:50.0f/255.0f green:50.0f/255.0f blue:50.0f/255.0f alpha:1.0f])

// 方格个数转成高度
#define LITTLE_SQUARE_TO_HEIGHT(x)  (x * 163.f / 25.4f)


typedef NS_ENUM(NSUInteger, ECG_DR_LINE_FRQ) {
    ECG_DR_LINE_FRQ_512,
    ECG_DR_LINE_FRQ_500,
};


@interface LTRingEcgDrawLineView : UIView

@property(strong, nonatomic)UIColor *gridLineColor;
@property(strong, nonatomic)UIColor *ecgLineColor;

@property(assign, nonatomic)NSInteger direction; //左右手

-(void)setHorizonalSpeed:(HORIZONTAL_SPEED)speedType VertialGain:(VERTIAL_GAIN)vGain;

/// reset
/// must call reset() before ecg measure start
-(void)reset;

-(void)updateValue:(CGFloat)ecgValue;
-(void)updateValues:(NSArray<NSNumber *> *)ecgValueArray;

-(CGFloat)calcHistoryWidth:(NSInteger)count;
-(void)drawAllData:(NSArray<NSNumber *> *)allData;

-(void)setFreqType:(ECG_DR_LINE_FRQ)frqType;

@end

@interface LTHmEcgDrawLineModel : NSObject

@property(assign, nonatomic)CGFloat ecgWaveValue;
@property(assign, nonatomic)CGFloat pointX;
@property(assign, nonatomic)CGFloat pointY;

- (instancetype)initWithWave:(CGFloat)wave;

@end


NS_ASSUME_NONNULL_END
